package com.zhc.dejingapi.controller;


import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhc.dejingapi.entity.QingWaterboiltaskstartEntity;
import com.zhc.dejingapi.entity.vo.WaterBoilTaskVo;
import com.zhc.dejingapi.service.QingWaterboiltaskstartService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 水煮开始任务表 前端控制器
 * </p>
 *
 * @author zhc
 * @since 2024-08-10
 */
@RestController
@RequestMapping("/qing-waterboiltaskstart-entity")
@CrossOrigin
public class QingWaterboiltaskstartController {

    //@Resource
    private final QingWaterboiltaskstartService qingWaterboiltaskstartService;

    public QingWaterboiltaskstartController(QingWaterboiltaskstartService qingWaterboiltaskstartService1) {
        this.qingWaterboiltaskstartService = qingWaterboiltaskstartService1;
    }

    @PostMapping("/getInfo/{cartonCode}")
    public WaterBoilTaskVo getInfo(@PathVariable String cartonCode) {
        QueryWrapper<QingWaterboiltaskstartEntity> query = new QueryWrapper<>();
        query.eq("cartonCode",cartonCode);
        QingWaterboiltaskstartEntity one = qingWaterboiltaskstartService.getOne(query);
        WaterBoilTaskVo waterBoilTaskVo = new WaterBoilTaskVo();
        waterBoilTaskVo.setNeedBoilTime(one.getNeedBoilTime());
        waterBoilTaskVo.setFinishedQty(one.getFinishedQty());
        waterBoilTaskVo.setInvCode(one.getInvCode());
        waterBoilTaskVo.setInvName(one.getInvName());
        waterBoilTaskVo.setPlanQty(one.getPlanQty());
        waterBoilTaskVo.setWorkTaskCode(one.getWorkTaskCode());
        waterBoilTaskVo.setEachCartonQty(one.getEachCartonQty());
        waterBoilTaskVo.setPlanEndTime(LocalDateTimeUtil.format(one.getPlanEndTime(), DatePattern.NORM_DATETIME_PATTERN));
        waterBoilTaskVo.setStartBoilTime(LocalDateTimeUtil.format(one.getStartBoilTime(), DatePattern.NORM_DATETIME_PATTERN));
        waterBoilTaskVo.setCartonName(one.getCartonName());
        waterBoilTaskVo.setBoilStartRowNo(one.getQingRowCode());
        waterBoilTaskVo.setEachCartonQty(one.getEachCartonQty());
        return waterBoilTaskVo;
    }
}
